home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / gradient-example.scm < prev    next >
Encoding:
Text File  |  2009-08-19  |  2.5 KB  |  76 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Gradient example script --- create an example image of a custom gradient
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software: you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 3 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20.  
  21. (define (script-fu-gradient-example width
  22.                                     height
  23.                                     gradient-reverse)
  24.   (let* (
  25.         (img (car (gimp-image-new width height RGB)))
  26.         (drawable (car (gimp-layer-new img width height RGB
  27.                                        "Gradient example" 100 NORMAL-MODE)))
  28.  
  29.         ; Calculate colors for checkerboard... just like in the gradient editor
  30.  
  31.         (fg-color (* 255 (/ 2 3)))
  32.         (bg-color (* 255 (/ 1 3)))
  33.         )
  34.  
  35.     (gimp-image-undo-disable img)
  36.     (gimp-image-add-layer img drawable 0)
  37.  
  38.     ; Render background checkerboard
  39.  
  40.     (gimp-context-push)
  41.  
  42.     (gimp-context-set-foreground (list fg-color fg-color fg-color))
  43.     (gimp-context-set-background (list bg-color bg-color bg-color))
  44.     (plug-in-checkerboard RUN-NONINTERACTIVE img drawable 0 8)
  45.  
  46.     (gimp-context-pop)
  47.  
  48.     ; Render gradient
  49.  
  50.     (gimp-edit-blend drawable CUSTOM-MODE NORMAL-MODE
  51.                      GRADIENT-LINEAR 100 0 REPEAT-NONE gradient-reverse
  52.                      FALSE 0 0 TRUE
  53.                      0 0 (- width 1) 0)
  54.  
  55.     ; Terminate
  56.  
  57.     (gimp-image-undo-enable img)
  58.     (gimp-display-new img)
  59.   )
  60. )
  61.  
  62. (script-fu-register "script-fu-gradient-example"
  63.     _"Custom _Gradient..."
  64.     _"Create an image filled with an example of the current gradient"
  65.     "Federico Mena Quintero"
  66.     "Federico Mena Quintero"
  67.     "June 1997"
  68.     ""
  69.     SF-ADJUSTMENT _"Width"            '(400 1 2000 1 10 0 1)
  70.     SF-ADJUSTMENT _"Height"           '(30 1 2000 1 10 0 1)
  71.     SF-TOGGLE     _"Gradient reverse" FALSE
  72. )
  73.  
  74. (script-fu-menu-register "script-fu-gradient-example"
  75.                          "<Gradients>")
  76.